package com.yxhl.zoume.domain.interactor.coupon;

import com.yxhl.zoume.data.http.repository.coupon.CouponRepository;
import com.yxhl.zoume.data.http.rest.param.base.RequestParamImpl;
import com.yxhl.zoume.data.http.rest.param.coupon.CurrentCouponParam;
import com.yxhl.zoume.data.http.rest.response.coupon.CurrentCouponResponse;
import com.yxhl.zoume.domain.DomainConstants;
import com.yxhl.zoume.domain.interactor.base.UseCase;

import javax.inject.Inject;
import javax.inject.Named;

import rx.Observable;
import rx.Scheduler;

/**
 * Created by vhawk on 2016/11/3.
 */
public class CurrentCouponUseCase extends UseCase<CurrentCouponResponse> {

    private final CouponRepository repository;

    @Inject
    public CurrentCouponUseCase(@Named(DomainConstants.UI_THREAD) Scheduler uiThread,
                                @Named(DomainConstants.EXECUTOR_THREAD) Scheduler executorThread,
                                CouponRepository repository) {
        super(uiThread, executorThread);
        this.repository = repository;
    }

    @Override
    protected Observable<CurrentCouponResponse> buildObservable(RequestParamImpl param) {
        return repository.fetchCurrentCoupons((CurrentCouponParam) param)
                .subscribeOn(executorThread)
                .observeOn(uiThread);
    }
}
